package com.zenithmind.library.service;

import com.zenithmind.common.result.PageResult;
import com.zenithmind.common.result.Result;
import com.zenithmind.library.pojo.dto.BookReviewCreateDTO;
import com.zenithmind.library.pojo.dto.BookReviewUpdateDTO;
import com.zenithmind.library.pojo.query.BookReviewQuery;
import com.zenithmind.library.pojo.vo.BookReviewVO;

import java.util.List;

/**
 * 图书评价服务接口
 * 遵循接口隔离原则：只包含图书评价相关的业务方法
 * 
 * @author ZenithMind
 * @since 2024-06-14
 */
public interface BookReviewService {

    /**
     * 分页查询图书评价
     * 
     * @param query 查询条件
     * @return 分页结果
     */
    PageResult<BookReviewVO> getBookReviewPage(BookReviewQuery query);

    /**
     * 根据ID查询图书评价详情
     * 
     * @param id 评价ID
     * @return 评价详情
     */
    Result<BookReviewVO> getBookReviewById(String id);

    /**
     * 根据图书ID查询评价列表
     * 
     * @param bookId 图书ID
     * @param limit 限制数量
     * @return 评价列表
     */
    Result<List<BookReviewVO>> getBookReviewsByBookId(String bookId, Integer limit);

    /**
     * 根据用户ID查询评价列表
     * 
     * @param userId 用户ID
     * @param limit 限制数量
     * @return 评价列表
     */
    Result<List<BookReviewVO>> getBookReviewsByUserId(String userId, Integer limit);

    /**
     * 创建图书评价
     * 
     * @param createDTO 创建参数
     * @return 创建结果
     */
    Result<BookReviewVO> createBookReview(BookReviewCreateDTO createDTO);

    /**
     * 更新图书评价
     * 
     * @param id 评价ID
     * @param updateDTO 更新参数
     * @return 更新结果
     */
    Result<BookReviewVO> updateBookReview(String id, BookReviewUpdateDTO updateDTO);

    /**
     * 删除图书评价
     * 
     * @param id 评价ID
     * @return 删除结果
     */
    Result<Void> deleteBookReview(String id);

    /**
     * 批量删除图书评价
     * 
     * @param ids 评价ID列表
     * @return 删除结果
     */
    Result<Void> batchDeleteBookReviews(List<String> ids);

    /**
     * 点赞评价
     * 
     * @param id 评价ID
     * @param userId 用户ID
     * @return 操作结果
     */
    Result<Void> likeReview(String id, String userId);

    /**
     * 取消点赞评价
     * 
     * @param id 评价ID
     * @param userId 用户ID
     * @return 操作结果
     */
    Result<Void> unlikeReview(String id, String userId);

    /**
     * 举报评价
     * 
     * @param id 评价ID
     * @param userId 举报用户ID
     * @param reason 举报原因
     * @return 操作结果
     */
    Result<Void> reportReview(String id, String userId, String reason);

    /**
     * 审核评价
     * 
     * @param id 评价ID
     * @param status 审核状态
     * @param auditReason 审核原因
     * @return 操作结果
     */
    Result<Void> auditReview(String id, Integer status, String auditReason);

    /**
     * 获取图书评价统计
     * 
     * @param bookId 图书ID
     * @return 统计信息
     */
    Result<BookReviewStatisticsVO> getBookReviewStatistics(String bookId);

    /**
     * 检查用户是否已评价图书
     * 
     * @param bookId 图书ID
     * @param userId 用户ID
     * @return 是否已评价
     */
    boolean hasUserReviewedBook(String bookId, String userId);

    /**
     * 导入图书评价数据
     * 
     * @param reviews 评价列表
     * @return 导入结果
     */
    Result<String> importBookReviews(List<BookReviewCreateDTO> reviews);

    /**
     * 导出图书评价数据
     * 
     * @param query 查询条件
     * @return 导出结果
     */
    Result<String> exportBookReviews(BookReviewQuery query);

    /**
     * 图书评价统计VO
     */
    class BookReviewStatisticsVO {
        private Integer totalReviews;
        private Double averageRating;
        private Integer fiveStarCount;
        private Integer fourStarCount;
        private Integer threeStarCount;
        private Integer twoStarCount;
        private Integer oneStarCount;
        private Integer likeCount;
        private Integer reportCount;

        // getters and setters
        public Integer getTotalReviews() { return totalReviews; }
        public void setTotalReviews(Integer totalReviews) { this.totalReviews = totalReviews; }
        
        public Double getAverageRating() { return averageRating; }
        public void setAverageRating(Double averageRating) { this.averageRating = averageRating; }
        
        public Integer getFiveStarCount() { return fiveStarCount; }
        public void setFiveStarCount(Integer fiveStarCount) { this.fiveStarCount = fiveStarCount; }
        
        public Integer getFourStarCount() { return fourStarCount; }
        public void setFourStarCount(Integer fourStarCount) { this.fourStarCount = fourStarCount; }
        
        public Integer getThreeStarCount() { return threeStarCount; }
        public void setThreeStarCount(Integer threeStarCount) { this.threeStarCount = threeStarCount; }
        
        public Integer getTwoStarCount() { return twoStarCount; }
        public void setTwoStarCount(Integer twoStarCount) { this.twoStarCount = twoStarCount; }
        
        public Integer getOneStarCount() { return oneStarCount; }
        public void setOneStarCount(Integer oneStarCount) { this.oneStarCount = oneStarCount; }
        
        public Integer getLikeCount() { return likeCount; }
        public void setLikeCount(Integer likeCount) { this.likeCount = likeCount; }
        
        public Integer getReportCount() { return reportCount; }
        public void setReportCount(Integer reportCount) { this.reportCount = reportCount; }
    }
}
